import type { ComponentInternalInstance } from "vue";
import { getCurrentInstance } from "vue";
import type { RouteLocationNormalizedLoaded, Router } from "vue-router";

/**
 * 返回全局工具
 * return {echarts,router,route}
 * echarts：图表，文档 - https://echarts.apache.org/examples/zh/index.html#chart-type-pie
 */
export default function useCurrentInstance() {
  const { appContext } = getCurrentInstance() as ComponentInternalInstance;
  const proxy = appContext.config.globalProperties;
  const echarts = proxy.$echarts;
  const router:Router = proxy.$router;
  const route:RouteLocationNormalizedLoaded = proxy.$route;
  return { echarts, router, route };
}